﻿#ifndef LFFRAMEHELPERPRIVATE_H
#define LFFRAMEHELPERPRIVATE_H

#include <QObject>
#include <QPoint>
#include <QMargins>

class QEvent;
class QTimer;
class QWidget;
class QMouseEvent;
class QAbstractButton;
class FrameHelperPrivate : public QObject
{
    Q_OBJECT
public:
    QWidget *parent;
	QAbstractButton *btnClose;
	QAbstractButton *btnMinimized;
	QAbstractButton *btnMaxRestore;

    QList<QWidget *> dragWidgets;
    QList<QWidget *> edgeWidgets;
    QMargins margins;

    FrameHelperPrivate(QWidget *parent);
    void addEdgeWidget(QWidget *widget);
    void addDragWidget(QWidget *widget);

public slots:
	void refreshMaximizedButton();

protected:
    enum MoveDirection {
        None = 0,
        Left,
        Right,
        LeftTop,
        RightTop,
        LeftBottom,
        RightBottom,
        Top,
        Bottom,
    };

    enum MoveOperation {
        MoveNone = 0,
        MoveResize,
        MoveDrag,
    };

protected:
    bool eventFilter(QObject *obj, QEvent *event);

private slots:
    void checkPos();

    void resize(const QPoint &cursorPos);

private:
    bool isMaximized;
    MoveDirection direction;
    MoveOperation operation;

    bool isMousePressed;

    QTimer *timer;

    QPoint dragBasePoint;
};

#endif // FRAMELESSHELPERPRIVATE_H